package com.sdy.redis.service;

import java.util.List;
import java.util.Set;

/**
 * Created by zzq on 2017-08-23.
 */
public interface RedisService {
    /**
     * 设置缓存对象
     *
     * @param key
     * @param value
     */
    void set(String key, Object value);

    void set(String key, Object value, int seconds);

    /**
     * 获取缓存对象
     *
     * @param key
     * @return
     */
    <T> T get(String key, Class<T> clazz);
    <T> T getOrDefault(String key, Class<T> clazz, T defaultValue);

    Boolean setnx(String key, Object value);

    Boolean setnx(String key, Object value, int seconds);

    /**
     * 删除缓存对象
     *
     * @param key
     */
    Boolean del(String key);

    /**
     * 批量删除
     *
     * @param regx
     */
    void delRegx(String regx);

    Boolean exists(String key);

    Long incr(String key);

    Long incr(String key, Long delta);


    Long ttl(String key);

    Boolean expire(String key, Integer seconds);

    ////////////////// 集合操作 ////////////////
    
    Long sadd(String key, Object... value);

    Long sremove(String key, Object... value);

    Long scard(String key);

    Set<Object> smember(String key);

    Long rpush(String key, Object value);
    
    Long llen(String key);
    
    List lrange(String key, int start, int end);

    Set<String> keys(String regx);
}
